<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <style>
    #app {
      width: 300px;
      height: 300px;
      background-color: aqua;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 30px;
      color: blue;
    }
  </style>
  <body>
    <div id="app">1234</div>

    <div>
      <button id="goto" onclick="ddd()">开始</button>
      <button id="www" onclick="bbb()">stop</button>
    </div>
  </body>
  <script>
    let name = [
      "鱼香肉丝米饭",
      "水果捞",
      "鸭腿饭",
      "火锅",
      "烤肉",
      "麻辣烫",
      "烤冷面",
    ];
    let timer = null,
      index = 0;

    let content = document.getElementById("app");
    // let hyh=document.getElementById('goto')
    content.innerText = name[index];
    function ddd() {
      timer = setInterval(() => {
        index = Math.floor(Math.random() * name.length);
        content.innerText = name[index];
      }, 80);
    }
    function bbb() {
      clearInterval(timer);
      return false;
    }
  </script>
</html>
